package cn.stylefeng.guns.modular.gsb.controller;

import cn.stylefeng.guns.modular.gsb.pojo.request.GsbRequest;
import cn.stylefeng.guns.modular.gsb.service.GsbService;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 公司表控制器
 *
 * @author zhu
 * @date 2021/10/06 11:04
 */
@RestController
@ApiResource(name = "公司表")
public class GsbController {

    @Resource
    private GsbService gsbService;

    /**
     * 添加
     *
     * @author zhu
     * @date 2021/10/06 11:04
     */
    @PostResource(name = "添加", path = "/gsb/add")
    public ResponseData add(@RequestBody @Validated(GsbRequest.add.class) GsbRequest gsbRequest) {
        gsbService.add(gsbRequest);
        return new SuccessResponseData();
    }

    /**
     * 删除
     *
     * @author zhu
     * @date 2021/10/06 11:04
     */
    @PostResource(name = "删除", path = "/gsb/delete")
    public ResponseData delete(@RequestBody @Validated(GsbRequest.delete.class) GsbRequest gsbRequest) {
        gsbService.del(gsbRequest);
        return new SuccessResponseData();
    }

    /**
     * 编辑
     *
     * @author zhu
     * @date 2021/10/06 11:04
     */
    @PostResource(name = "编辑", path = "/gsb/edit")
    public ResponseData edit(@RequestBody @Validated(GsbRequest.edit.class) GsbRequest gsbRequest) {
        gsbService.edit(gsbRequest);
        return new SuccessResponseData();
    }

    /**
     * 查看详情
     *
     * @author zhu
     * @date 2021/10/06 11:04
     */
    @GetResource(name = "查看详情", path = "/gsb/detail")
    public ResponseData detail(@Validated(GsbRequest.detail.class) GsbRequest gsbRequest) {
        return new SuccessResponseData(gsbService.detail(gsbRequest));
    }

    /**
     * 获取列表
     *
     * @author zhu
     * @date 2021/10/06 11:04
     */
    @GetResource(name = "获取列表", path = "/gsb/list")
    public ResponseData list(GsbRequest gsbRequest) {
        return new SuccessResponseData(gsbService.findList(gsbRequest));
    }

    /**
     * 获取列表（带分页）
     *
     * @author zhu
     * @date 2021/10/06 11:04
     */
    @GetResource(name = "分页查询", path = "/gsb/page")
    public ResponseData page(GsbRequest gsbRequest) {
        return new SuccessResponseData(gsbService.findPage(gsbRequest));
    }

}